Declaring variables in FBD
Use one of the following possibilities to declare one or more →variables within a →POU in →FBD:
In this article: |
---|
Good to know |
---|
You are able to change some properties of an already declared variable later on. See under "Modifying variables" for the possibilities. If you require a →constant, →retentive or →non-retentive variable, use the content assist. At present, Neuron Power Engineer supports only this possibility to declare such variables. The application navigator provides the possibility to declare external variables and to have the declarations based on the already existing global variables. This is done when you drag the global variables from a global-object onto a →POU. Details: See "Declaring external variables by dragging and dropping global variables into POUs". It is also possible to copy and paste variables and/or instances in order to declare new variables/instances based on already existing variables/instances. |
Creating variables by using a dialog in the list of the declared variables
-
Make the list of declared variables visible.
Alternative for an →input variable, →output variable or →in-/out variable: Open the interface editor for the object (from within the project explorer). -
From the context menu, select New Variable... Alternative: Press the Ctrl-key and the +-key.
-
In the dialog, enter the following properties for the variable and click OK.
-
name – The name must be an →IEC-identifier.
If you want to declare several variables in one go, enter the name with,
separating the names. Example:UpErr, QuitErr, MotorUp, MotorDown
-
section (= the variable section), e.g.
LOCAL
(for →local variable, also known as →internal variable),INPUT
(for →input variable) etc.Restrictions
→Temporary variables are not possible in FBD. →In-out variables cannot be declared in a →program, →global variables cannot be declared in a →function block or →function.
-
-
→data type or →function block type
Multi-dimensional array data types are not supported for connecting to a block in-/output with a →generic data type (e.g. the in-/output of theMOVE
block).
Enter one or several letters so that a selection list with the corresponding data types and function blocks is provided.
Subsequent changes to the selection are possible, e.g. by completing an →ARRAY declaration. For theSTRING
data type,STRING[80]
is automatically entered. Overwrite80
, if you need a different length for theSTRING
variable. -
→initial value (only optional required) – This initial value may be a →constant expression (in compliance with the →data type).
It is not possible to assign an initial value to an →external variable
Creating a Boolean local variable fast
-
Make the list of declared variables visible.
-
From the context menu, select New Variable (LOCAL, BOOL). Alternative: Press Ctrl+Shift and the +-key.
If necessary, you are able to change the name as well as the data type later on. See under "Modifying variables".
Creating value fields with new variables
Use the command Variable(s) in the context menu of the drawing field to create one or more →value fields with the new variables. The necessary variables are automatically declared.
-
Position the mouse pointer over an empty space of the →graphical FBD-editor – where you need the value field.
-
In the context menu of the FBD-editor, select Create and Variable(s). Alternative: Press Ctrl+Shift+V.
-
In the dialog, enter the properties for the variable and click OK.
This entry is analogous to the one described in "Creating variables by using a dialog in the list of the declared variables". -
Position the value field by pressing the primary mouse button or the Enter-key. The corresponding variables will be declared automatically, which makes them appear in the list of declared variables. This list is automatically displayed in this variant of creation.
Creating values fields with new variables (by using the content assist)
Use the content assist in order to create one or more value fields with the new variables. The necessary variables are automatically declared.
-
Position the mouse pointer over an empty space of the graphical FBD-editor – where you need the value field.
-
Double-click or press Ctrl+Space.
Result: An input field is opened. -
Declare the variables according to this syntax:
X, Y : name_1, name_2, ..., name_n : type := initial-value
(with the partsX, Y :
and:=initial-value
being optional). -
Press the Enter-key.
Result: The preview of the value field is displayed.
Result, if the variable already exists with a different data type: This conflict is reported. In this case, change the name of the variable to a unique name and press the Enter-key again. -
Position the value field by pressing the primary mouse button or the Enter-key.
Result, if the variable has not been declared yet: The necessary variables are automatically declared. Hence, the variables are listed in the list of the declared variables.
Result, if the variable already exists with a different sectionX
: This conflict is not reported. The existing variable of the different section is entered in the value field.
See "Creating value fields or calls of blocks by using the content assist in FBD", if you need more information on creating value fields.
Examples |
---|
|
Explanation of the syntax
Prefix "X" |
---|
Instead of
|
Prefix "Y" |
---|
Instead of
|
Name of variable |
---|
Instead of |
Possible types |
---|
Instead of |
Initial value |
---|
Instead of |